package com.example.demo.pojo;

import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * <h3>reqister</h3>
 * <p>分页辅助类</p>
 *
 * @author : chenjunjie
 **/
@Setter
@NoArgsConstructor
public class Page {


    /**
     * 当前页数
     */
    private int currentPage;
    private int pageSize;

    /**
     * 总条数
     */
    private int totalCount;

    public Page(int currentPage, int pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    /**
     * 返回总页数
     * @return totalCount
     */
    public int getTotalCount() {
        return totalCount % pageSize==0?totalCount/pageSize:totalCount/pageSize+1;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
}
